using AutoMapper;
using hao_Common.AutoMapper.Profiles;
using hao_Dto;
using hao_Model;
using System;

namespace hao_Common.AutoMapper.Profiles
{
    /// <summary>
    /// 订单相关映射配置
    /// </summary>
    public class OrderProfile : BaseProfile
    {
        public OrderProfile()
        {
            // Order 到 OrderResponseDto 的映射
            CreateMap<Order, OrderResponseDto>()
                .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id))
                .ForMember(dest => dest.OrderNumber, opt => opt.MapFrom(src => src.OrderNumber))
                .ForMember(dest => dest.BuyerId, opt => opt.MapFrom(src => src.BuyerId))
                .ForMember(dest => dest.SellerId, opt => opt.MapFrom(src => src.SellerId))
                .ForMember(dest => dest.ProductId, opt => opt.MapFrom(src => src.ProductId))
                .ForMember(dest => dest.ProductTitle, opt => opt.MapFrom(src => src.ProductTitle))
                .ForMember(dest => dest.ProductPrice, opt => opt.MapFrom(src => src.ProductPrice))
                .ForMember(dest => dest.FinalPrice, opt => opt.MapFrom(src => src.FinalPrice))
                .ForMember(dest => dest.Quantity, opt => opt.MapFrom(src => src.Quantity))
                .ForMember(dest => dest.TotalAmount, opt => opt.MapFrom(src => src.TotalAmount))
                .ForMember(dest => dest.DeliveryMethod, opt => opt.MapFrom(src => src.DeliveryMethod))
                .ForMember(dest => dest.Status, opt => opt.MapFrom(src => src.Status))
                .ForMember(dest => dest.PaymentStatus, opt => opt.MapFrom(src => src.PaymentStatus))
                .ForMember(dest => dest.DeliveryStatus, opt => opt.MapFrom(src => src.DeliveryStatus))
                .ForMember(dest => dest.TrackingNumber, opt => opt.MapFrom(src => src.TrackingNumber))
                .ForMember(dest => dest.BuyerMessage, opt => opt.MapFrom(src => src.BuyerMessage))
                .ForMember(dest => dest.SellerMessage, opt => opt.MapFrom(src => src.SellerMessage))
                .ForMember(dest => dest.CreatedAt, opt => opt.MapFrom(src => src.CreatedAt))
                .ForMember(dest => dest.PaidAt, opt => opt.MapFrom(src => src.PaidAt))
                .ForMember(dest => dest.ShippedAt, opt => opt.MapFrom(src => src.ShippedAt))
                .ForMember(dest => dest.DeliveredAt, opt => opt.MapFrom(src => src.DeliveredAt))
                .ForMember(dest => dest.CompletedAt, opt => opt.MapFrom(src => src.CompletedAt))
                .ForMember(dest => dest.BuyerName, opt => opt.Ignore())
                .ForMember(dest => dest.SellerName, opt => opt.Ignore())
                .ForMember(dest => dest.DeliveryMethodName, opt => opt.Ignore())
                .ForMember(dest => dest.StatusName, opt => opt.Ignore())
                .ForMember(dest => dest.PaymentStatusName, opt => opt.Ignore())
                .ForMember(dest => dest.DeliveryStatusName, opt => opt.Ignore())
                .ForMember(dest => dest.BuyerAddress, opt => opt.Ignore());

            // Order 到 OrderListDto 的映射
            CreateMap<Order, OrderListDto>()
                .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id))
                .ForMember(dest => dest.OrderNumber, opt => opt.MapFrom(src => src.OrderNumber))
                .ForMember(dest => dest.ProductTitle, opt => opt.MapFrom(src => src.ProductTitle))
                .ForMember(dest => dest.FinalPrice, opt => opt.MapFrom(src => src.FinalPrice))
                .ForMember(dest => dest.Quantity, opt => opt.MapFrom(src => src.Quantity))
                .ForMember(dest => dest.TotalAmount, opt => opt.MapFrom(src => src.TotalAmount))
                .ForMember(dest => dest.Status, opt => opt.MapFrom(src => src.Status))
                .ForMember(dest => dest.PaymentStatus, opt => opt.MapFrom(src => src.PaymentStatus))
                .ForMember(dest => dest.CreatedAt, opt => opt.MapFrom(src => src.CreatedAt))
                .ForMember(dest => dest.StatusName, opt => opt.Ignore())
                .ForMember(dest => dest.PaymentStatusName, opt => opt.Ignore())
                .ForMember(dest => dest.BuyerName, opt => opt.Ignore())
                .ForMember(dest => dest.SellerName, opt => opt.Ignore());

            // CreateOrderDto 到 Order 的映射
            CreateMap<CreateOrderDto, Order>()
                .ForMember(dest => dest.Id, opt => opt.Ignore())
                .ForMember(dest => dest.OrderNumber, opt => opt.Ignore())
                .ForMember(dest => dest.BuyerId, opt => opt.Ignore())
                .ForMember(dest => dest.SellerId, opt => opt.Ignore())
                .ForMember(dest => dest.ProductTitle, opt => opt.Ignore())
                .ForMember(dest => dest.ProductPrice, opt => opt.Ignore())
                .ForMember(dest => dest.TotalAmount, opt => opt.Ignore())
                .ForMember(dest => dest.Status, opt => opt.Ignore())
                .ForMember(dest => dest.PaymentStatus, opt => opt.Ignore())
                .ForMember(dest => dest.DeliveryStatus, opt => opt.Ignore())
                .ForMember(dest => dest.CreatedAt, opt => opt.Ignore())
                .ForMember(dest => dest.UpdatedAt, opt => opt.Ignore())
                .ForMember(dest => dest.IsDeleted, opt => opt.MapFrom(src => false));
        }
    }
}